//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<XGfxFade.h>
///	@path	~/src/appear/xgfx/
///	@date	2008/10/14
///	@brief	.

#pragma once

#include "xeres.h"

#include "graphics/IEffect.h"
#include "graphics/ITechnique.h"
#include "graphics/IShaderVariable.h"

#include "appear/xgfx/XGfxSlide.h"

namespace xeres {

	/*! 
		\class	XGfxFade
		\brief
	*/
	class XGfxFade : public IGuiEffect
	{
	public:

		/// \ctor
		XGfxFade( void );

		/// \dtor
		virtual ~XGfxFade( void );

		DECL_IOBJECT_CLASS_DYNAMIC( XGfxFade , IGuiEffect );

	public:

		/// \name Effect Interface.
		//@{

		/// \brief	Set effect component.
		virtual void SetComp( RefWeak<IGuiComp> comp );

		/// \brief	Get effect component.
		virtual RefWeak<IGuiComp> GetComp( void );

		/// \brief	Set param.
		virtual bool SetParam( const WString& name , Ref<IVar> val );

		/// \brief	Get param.
		virtual RefPass<IVar> GetParam( const WString& name );

		/// \brief	Get param list.
		virtual StringSeq GetParamList( void );

		/// \brief	Reset effect.
		virtual void Reset( void );

		/// \brief	Tick update (returning false indicates detach effect).
		virtual bool Tick( float dTime );

		/// \brief	Render effect.
		virtual void Render( RenderContext& rc , RefWeak<ITexture> texture );

		//@}

		enum FadeType
		{
			FADE_IN  = 0 ,
			FADE_OUT = 1 ,
			FADE_last
		};

	private:

		// @ data
		Ref<IGuiComp>	m_comp;

		// parameters.
		float			m_paramElapse;
		int				m_paramFadeType; // 0 - Fade in , 1 - Fade out.

		// running state.
		float			m_tickElapsed;

		// effect of gfx
		Ref<IEffect>			m_effect;
		Ref<ITechnique>			m_technique;
		Ref<IShaderVariable>	m_texture;
		Ref<IShaderVariable>	m_alpha;
	};

} // namespace xeres
